import {request} from './request'

// 添加地址
export function addAddress(data) {
    return request({
        url: `/api/address`,
        method: 'post',
        data
    })
}

// 地址列表
export function getAddressList() {
    return request({
        url: `/api/address`,
    })
}

// 地址详情
export function getAddressDetail(id) {
    return request({
        url: `/api/address/${id}`
    })
}

// 更新地址
export function editAddress(id, data) {
    return request({
        url: `/api/address/${id}`,
        method: 'put',
        data
    })
}

// 删除地址
export function deleteAddress(id) {
    return request({
        url: `/api/address/${id}`,
        method: 'delete'
    })
}

// 设置为默认地址
export function defaultAddress(id) {
    return request({
        url: `/api/address/${id}/default`,
        method: 'patch'
    })
}